package ua.maxicash.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import ua.maxicash.service.GeoService;
import ua.maxicash.vo.City;

import java.util.List;

@Controller
@RequestMapping(value = "/search")
public class SearchController {

    @Autowired
    GeoService geoService;

    @RequestMapping(value = "/cities")
    @ResponseBody
    public List<City> searchForCity(@RequestParam("term") String term){

        List<City> cities = geoService.getCitiesLike(term);
        return cities;
    }


}
